﻿using System;
using System.Globalization;
using System.Xml.Serialization;

namespace TwitterXml
{
    [XmlRootAttribute(ElementName = "status", IsNullable = false)]
    public class Status
    {

        #region Private Fields

        private string created_at;
        private int id;
        private string text;
        private string source;
        private bool truncated;
        private string in_reply_to_status_id;
        private string in_reply_to_user_id;
        private bool favorited;
        private string in_reply_to_screen_name;
        private User user;

        #endregion Private Fields


        #region Public Properties

        [XmlElement(ElementName = "created_at")]
        public string Created_At
        {
            get { return created_at; }
            set { created_at = value; }
        }

        [XmlIgnore]
        public DateTime CreatedAt
        {
            get 
            { 
                return DateTime.ParseExact(
                created_at,
                Twitter.CreatedAtDateFormat, 
                CultureInfo.CurrentCulture, DateTimeStyles.AllowWhiteSpaces); 
            }
            set { created_at = value.ToString(Twitter.CreatedAtDateFormat); }
        }

        [XmlElement(ElementName = "id")]
        public int Id
        {
            get { return id; }
            set { id = value; }
        }

        [XmlElement(ElementName = "text")]
        public string Text
        {
            get { return text; }
            set { text = value; }
        }

        [XmlElement(ElementName = "source")]
        public string Source
        {
            get { return source; }
            set { source = value; }
        }

        [XmlElement(ElementName = "truncated")]
        public bool Truncated
        {
            get { return truncated; }
            set { truncated = value; }
        }

        [XmlElement(ElementName = "in_reply_to_status_id")]
        public string In_Reply_To_Status_Id
        {
            get { return in_reply_to_status_id; }
            set { in_reply_to_status_id = value; }
        }

        [XmlElement(ElementName = "in_reply_to_user_id")]
        public string In_Reply_To_User_Id
        {
            get { return in_reply_to_user_id; }
            set { in_reply_to_user_id = value; }
        }

        [XmlElement(ElementName = "favorited")]
        public bool Favorited
        {
            get { return favorited; }
            set { favorited = value; }
        }

        [XmlElement(ElementName = "in_reply_to_screen_name")]
        public string In_Reply_To_Screen_Name
        {
            get { return in_reply_to_screen_name; }
            set { in_reply_to_screen_name = value; }
        }

        [XmlElement(ElementName = "user")]
        public User User
        {
            get { return user; }
            set { user = value; }
        }

        #endregion Public Properties


        #region Contructors

        public Status()
        {
        }

        public Status(string created_at, int id, string text, string source, bool truncated, string in_reply_to_status_id, string in_reply_to_user_id, bool favorited, string in_reply_to_screen_name, User user)
        {
            this.created_at = created_at;
            this.id = id;
            this.text = text;
            this.source = source;
            this.truncated = truncated;
            this.in_reply_to_status_id = in_reply_to_status_id;
            this.in_reply_to_user_id = in_reply_to_user_id;
            this.favorited = favorited;
            this.in_reply_to_screen_name = in_reply_to_screen_name;
            this.user = user;
        }

        #endregion Constructors

    }
}
